/* 
 * Advanced Foundation Classes
 * Copyright (C) 2000/2004  Fabio Rotondo - Andrea Galimberti
 *  
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *  
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *  
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
#include <afc/easygui/easygui.h>
#include <afc/easygui/widgets.h>

int radio_toggled ( DynamicClass * dc, EasyGUIContext * egui, short active, char * value )
{
        fprintf ( stderr, "Radio Button \"%s\" Selected! Active: %d\n", value, active );

        return ( 0 );
}

int btn_set ( DynamicClass * dc, EasyGUIContext * context )
{
	afc_easygui_widget_execute ( context, "r1", "set_value", 1, AFC_EASYGUI_ARG_END );
	return ( 0 );
}

int main ( int argc, char * argv[] )
{
	AFC * afc = afc_new (); 
	EasyGUI * easygui = afc_easygui_new ( afc );
	int afc_res = 0;

	if ( easygui == NULL ) 
	{
	  fprintf ( stderr, "Init of class EasyGUI failed.\n" );
	  return ( 1 );
	}

	afc_easygui_init ( easygui );

	afc_easygui_set_gui ( easygui, 
		"(window TITLE=\"EasyGUI: radiobutton\" MAINWIN "
                "	(rows "
                "		(radiobutton name=\"r1\" group=\"rad\" text=\"hello!\" 		value=\"hello\" action=radio_toggled )"
                "		(radiobutton name=\"r2\" group=\"rad\" text=\"beautiful\" 	value=\"beauty\" action=radio_toggled)"
                "		(radiobutton name=\"r3\" group=\"rad\" text=\"world!\" 		value=\"world\"  action=radio_toggled)"
		"		(separator) "
		"		(button text=\"Set #1\" action=\"btn_set\")"
		"	)"
		") "
	);

	if ( ( afc_res = afc_easygui_show ( easygui ) ) != AFC_ERR_NO_ERROR ) 
	{
		fprintf ( stderr, "res: %x\n", afc_res );
	} else 
		afc_easygui_main ( easygui );

	afc_easygui_delete ( easygui );
	afc_delete ( afc );

	return ( 0 ); 
}
